IdeaBlade.EntityModel.Compat Assembly > IdeaBlade.EntityModel Namespace > Coroutine Class > Start Method : Start(Func<CoroutineOperation,IEnumerable<Func<INotifyCompleted>>>,Action<CoroutineOperation>) Method |
'Declaration
Public Overloads Shared Function Start( _ ByVal asyncFns As Func(Of CoroutineOperation,IEnumerable(Of Func(Of INotifyCompleted))), _ Optional ByVal completedHandler As Action(Of CoroutineOperation) _ ) As CoroutineOperation
'Usage
Dim asyncFns As Func(Of CoroutineOperation,IEnumerable(Of Func(Of INotifyCompleted))) Dim completedHandler As Action(Of CoroutineOperation) Dim value As CoroutineOperation value = Coroutine.Start(asyncFns, completedHandler)
Use this overload of the Start method when your iterator accepts a CoroutineOperation as an argument. You can use the CoroutineOperation to track the prior operations within the function list.
This overload of the Start method is useful in Visual Basic, where iterators are not supported.
Public Sub CoroutineSample4() Dim mgr = New NorthwindIBEntities() Dim op = Coroutine.Start(Function(coop As CoroutineOperation) Sample3Actions(coop, mgr)) AddHandler op.Completed, Sub(s As Object, e As CoroutineCompletedEventArgs) If e.CompletedSuccessfully Then MessageBox.Show("OK") End If End Sub End Sub Private Function Sample3Actions(ByVal coop As CoroutineOperation, ByVal mgr As NorthwindIBEntities) As IEnumerable(Of Func(Of INotifyCompleted)) ' Setup of the list of async functions for the Coroutine to execute serially. Dim operationList = New List(Of Func(Of INotifyCompleted)) Dim f1 As Func(Of INotifyCompleted) = Function() mgr.Customers.Take(2).ExecuteAsync() operationList.Add(f1) Dim f2 As Func(Of INotifyCompleted) = Function() ' Use the results from the first async query. Dim firstOp = DirectCast(coop.Notifications.First(), EntityQueryOperation(Of Customer)) Dim customers = firstOp.Results Dim cityList = New List(Of String) customers.ForEach(Sub(cust As Customer) cityList.Add(cust.City)) Dim pd = New IdeaBlade.Linq.PredicateDescription(GetType(Order), "Shipcity", IdeaBlade.Linq.FilterOperator.InList, cityList) Return mgr.Orders.Where(pd).ExecuteAsync() End Function operationList.Add(f2) Return operationList End Function
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2